/*
 * create on 2008-10-6
 * Copy right (2008)
 * Author Tan Nailiang
 * HNA Systems All rights reserved
 */
package com.myway.dto.flight.domain;

import java.util.HashMap;

/**
 * 类名称：TripType 
 * 类描述：TODO 航班类型
 * 创建时间：2015年10月26日 下午4:25:17 
 * @author Jiang.Yida
 * @version V1.0
 */
public enum TripType {
	
	/**
	 * 单程
	 */
	ONEWAY("OW"),
	/**
	 * 往返
	 */
	RETURN("RT"),
	/**
	 * 多段
	 */
	MULTIWAY("MW"),
	/**
	 * 缺口程
	 */
	OPEN_JAW("OJ");
	
	private final String alias;
	private static HashMap<String, TripType> map;

	/**
	 * Construct the hash map at load time
	 */
	static {
		map = new HashMap<String, TripType>();
		for (TripType type : TripType.values()) {
			map.put(type.alias, type);
		}
	}

	TripType(String alias) {
		this.alias = alias;
	}

	@Override
	public String toString() {
		return this.alias;

	}

	/**
	 * Return a <code>TripType</code> object holding the value of specified alias name
	 * @param alias the alias name of the type
	 * @return a <code>TripType</code> object holding the value represented by the alias name argument
	 */
	public static TripType valueOfAlias(String alias) {
		TripType type = map.get(alias);

		if (type == null) {
			throw new IllegalArgumentException("Unknown trip type alias [" + alias + "]");
		}

		return type;
	}
	

}
